/**
 * Notes: 文件处理相关函数
 * Ver : CCMiniCloud Framework 2.7.1 ALL RIGHTS RESERVED BY cclinux0730 (wechat)
 * Date: 2022-02-05 04:00:00
 */
const pageHelper = require('./page_helper.js');
const timeHelper = require('./time_helper.js');
function openDoc(name, url, ext = '.xlsx') {
    uni.showLoading({
        title: '文件下载中'
    });
    uni.downloadFile({
        url,
        //fileID:' ',
        filePath: uni.env.USER_DATA_PATH + '/' + name + timeHelper.time('YMDhms') + ext,
        success: function (res) {
            uni.hideLoading();
            if (res.statusCode != 200) return pageHelper.showModal('打开文件失败，请重试或者采取别的下载方式');
            const filePath = res.filePath;
            uni.openDocument({
                showMenu: true,
                filePath: filePath,
                success: function (res) {
                    console.log('打开文档成功');
                }
            });
        },
        fail: function (err) {
            uni.hideLoading();
            console.log(err);
            pageHelper.showModal('打开文件失败，请重试或者采取别的下载方式');
        }
    });
}
module.exports = {
    openDoc
};
